﻿using Silverlight.Training.Client.Common.ServiceReference.EventArgs;
using Silverlight.Training.Client.Common.ServiceReference.Contracts;

namespace SilverLight.Training.Models
{
    public class EmployeeTypeDetailsModel : ModelBase
    {
        public event System.EventHandler<CollectionFeedbackCompletedEventArgs<EmployeeType>> GetEmployeeTypeCollectionCompleted;
        public event System.EventHandler<SingleFeedbackCompletedEventArgs<EmployeeType>> GetSingleEmployeeTypeCompleted;

        public EmployeeTypeDetailsModel() : base()
        {
            client.GetEmployeeTypeCollectionCompleted += client_GetEmployeeTypeCollectionCompleted;
            client.GetSingleEmployeeTypeCompleted += client_GetSingleEmployeeTypeCompleted;
        }

        public void GetEmployeeTypeCollectionAsync()
        {
            client.GetEmployeeTypeCollectionAsync();
        }

        public void GetSingleEmployeeTypeAsync(int eTypeID)
        {
            client.GetSingleEmployeeTypeAsync(eTypeID);
        }

        void client_GetSingleEmployeeTypeCompleted(object sender, SingleFeedbackCompletedEventArgs<EmployeeType> e)
        {
            if (GetSingleEmployeeTypeCompleted != null)
            {
                GetSingleEmployeeTypeCompleted(sender, e);
            }
        }

        void client_GetEmployeeTypeCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<EmployeeType> e)
        {
            if (GetEmployeeTypeCollectionCompleted != null)
            {
                GetEmployeeTypeCollectionCompleted(sender, e);
            }
        }
    }
}
